package com.java8.time.api;

import java.time.Clock;

/**
 * <p>Description: [Java 8的Clock时钟类]</p>
 * Created on 2020/2/21
 *
 * @author <a href="mailto: 819712047@qq.com">谢振东 </a>
 * @version 1.0
 */
public class Demo10 {

    /**
     * Java 8增加了一个Clock时钟类用于获取当时的时间戳，或当前时区下的日期时间信息。
     * 以前用到System.currentTimeInMillis()和TimeZone.getDefault()的地方都可用Clock替换。
     */
    public static void master() {
        System.out.println("-----------------Demo10.master()-----------------");
        // Returns the current time based on your system clock and set to UTC.
        Clock clock = Clock.systemUTC();
        System.out.println("Clock : " + clock.millis());

        // Returns time based on system clock zone
        Clock defaultClock = Clock.systemDefaultZone();
        System.out.println("Clock : " + defaultClock.millis());
    }
}
